﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Test
{
    public partial class InitForm : Form
    {
        public InitForm()
        {
            InitializeComponent();
            LoadData();
        }

        public void LoadData()
        {
            string path = Application.StartupPath + "\\init.txt";
            StreamReader sr = new StreamReader(path, Encoding.GetEncoding("utf-8"));
            List<Model> list = new List<Model>() { };
            String line;
            while ((line = sr.ReadLine()) != null)
            {
                
                Model model = new Model();
                string[] arr = line.Split(':');
                if (arr.Length == 2)
                {
                    model.wellName = arr[0].Replace(" ","");
                    model.serial = arr[1].Replace(" ","");
                    list.Add(model);
                }         
            }
            dataGridView1.DataSource = list;
            if (dataGridView1.ColumnCount == 2)
            {
                dataGridView1.Columns[0].HeaderText = "设备名称";
                dataGridView1.Columns[0].Width = 120;
                dataGridView1.Columns[1].HeaderText = "设备序列号";
                dataGridView1.Columns[1].Width = 223;

            }
        }

        public class Model
        {
            /// <summary>
            /// 设备名称
            /// </summary>
            public string wellName { get; set; }

            /// <summary>
            /// 序列号
            /// </summary>
            public string serial { get; set; }
        }
    }
}
